package com.winner.rabbitmq.rabbitmq;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * 消息消费者
 * @author wangxl
 * @date 2019-10-30
 */
@Component
@Slf4j
public class FirstConsumer {

    //mq只是用来环节压力
    //如果要开启多线程(多线程的个数在配置文件中修改), 注解内容加containerFactory = "rabbitListenerContainerFactory" 表示mq的多线程
    @RabbitListener(queues = {"first-queue","second-queue"}, containerFactory = "rabbitListenerContainerFactory")
    public void handleMessage(String message) throws Exception {
        //处理消息  异步来写文件
        Thread.sleep(5000);
        log.info("消费者从mq获取消息的内容为："+message);
    }

}
